package cn.zhong5.changzhoulocaltax.common.utils;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import cn.zhong5.changzhoulocaltax.R;

/**
 * Created by Sunman on 2017-11-24 0024.
 */

public class ToolbarHelper
{
    private Toolbar mToolbar;
    private TextView titleTV;
    private ImageView leftView;
    private ImageView rightView;

    public ToolbarHelper(Toolbar toolbar) {
        this.mToolbar = toolbar;
    }

    public Toolbar getToolbar() {
        return mToolbar;
    }

    public void setTitle(String title) {
        titleTV = (TextView) mToolbar.findViewById(R.id.toolbar_title);
        titleTV.setText(title);
    }

    public TextView getTitle() {
        return titleTV;
    }

    public void hideTitle() {
        getToolbar().setVisibility(View.GONE);
    }

    public void hideNavigation() {
        mToolbar.setNavigationIcon(null);
    }

    public void setLeftView(int resId) {
        leftView = (ImageView) mToolbar.findViewById(R.id.toolbar_img_left);
        leftView.setImageResource(resId);
    }

    public ImageView getLeftView () {
        return leftView;
    }

    public void hideLeftView() {
        leftView = (ImageView) mToolbar.findViewById(R.id.toolbar_img_left);
        leftView.setVisibility(View.GONE);
    }

    public void setRightView(int resId) {
        rightView = (ImageView) mToolbar.findViewById(R.id.toolbar_img_right);
        rightView.setImageResource(resId);
    }

    public ImageView getRightView () {
        return rightView;
    }

    public void hideRightView() {
        rightView = (ImageView) mToolbar.findViewById(R.id.toolbar_img_right);
        rightView.setVisibility(View.GONE);
    }
}
